package stream;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public class HelloStream {

	public static void main(String args[]) {

		//流Filter操作
		// testStreamFilter();
		

		List<User> users = new ArrayList<User>();
		users.add(new User(20, "fan"));
		users.add(new User(22, "zhi"));
		users.add(new User(10, "cheng"));
		users.add(new User(5, "Сar"));

		List<User> auditUsers = users.stream().filter(u -> u.getAge() > 20).collect(Collectors.toList());

		List<String> auditUsers2 = users.stream().filter((User user) -> user.getAge() > 20).map((User user) -> {
			return "50";
		}).collect(Collectors.toList());

	}
	
 
	

	public static void testStreamFilter() {
		List<String> list = Arrays.asList(new String[] { "fan", "zhao", "wang", "wang bao qiang" });
		List<String> resultList = list.stream().filter(p -> p.contains("wang")).collect(Collectors.toList());
		System.out.println(resultList.size());
	}

}
 